<template>
  <div class="page-common-layout custom-aboutPage-container">
    <div class="screen-conditions-container">
      <ScreenConditions :isDataType="false">
        <template slot="conditions">
          <a-input
            placeholder="请输入文件名称"
            style="width: 380px;"
            v-model="condition.fileName"
          ></a-input>
          <a-range-picker
            :placeholder="['上传开始时间', '上传结束时间']"
            format="YYYY-MM-DD HH:mm:ss"
            valueFormat="YYYY-MM-DD HH:mm:ss"
            v-model="condition.date"
            :show-time="{
              hideDisabledOptions: true,
              defaultValue: [
                moment('00:00:00', 'HH:mm:ss'),
                moment('11:59:59', 'HH:mm:ss'),
              ],
            }"
          />
          <a-input
            placeholder="请输入上传人"
            style="width: 380px;"
            v-model="condition.creator"
          ></a-input>
        </template>
        <template slot="operate">
          <a-button class="cu-btn-primary" icon="search" @click="search()">
            查询
          </a-button>
          <a-button class="cu-btn-filter" icon="reload" @click="reset()">
            重置
          </a-button>
        </template>
      </ScreenConditions>
    </div>
    <div class="about-body-container">
      <div class="about-left-container">
        <div class="sub-header">
          目录分项
          <!-- <a-button
            type="primary"
            v-action="'table_add_' + pageModule"
            icon="plus"
            @click="addFolder(0, '')"
          >
            新增目录
          </a-button> -->
          <div
            class="add-container"
            @click="addFolder(0, '')"
            v-action="'table_add_' + pageModule"
          >
            <icon-font type="icon-xinjianwenjianjia" class="add-file-button">
            </icon-font>
            新增目录
          </div>
        </div>
        <div class="tree-container">
          <a-empty
            v-if="treeData.length == 0"
            description="暂无数据，请先创建目录"
          >
            <a-button
              type="primary"
              icon="plus"
              v-action="'table_add_' + pageModule"
              @click="addFolder(0, '')"
            >
              创建目录
            </a-button>
          </a-empty>
          <a-tree
            v-else
            v-model="checkedKeys"
            show-icon
            show-line
            :expanded-keys="expandedKeys"
            :auto-expand-parent="autoExpandParent"
            :selected-keys="selectedKeys"
            :tree-data="treeData"
            :replaceFields="{
              children: 'children',
              title: 'nodeName',
              key: 'uuid',
            }"
            @expand="onExpand"
            @select="onSelect"
          >
            <!-- 自定义图标 -->
            <template slot="custom" slot-scope="{ expanded }">
              <a-icon
                :type="expanded ? 'folder-open' : 'folder'"
                theme="filled"
              />
            </template>
            <template
              slot="title"
              slot-scope="{ nodeName, id, uuid, delBtn, versionMain }"
            >
              <div class="custom-tree-title-warp">
                <div class="title" :title="nodeName">
                  {{ nodeName }}
                </div>
                <div class="operate">
                  <!-- 新增 -->
                  <icon-font
                    type="icon-xinjianwenjianjia"
                    class="add-file-button"
                    @click.stop="addFolder(id)"
                    v-if="versionMain != 1"
                    v-action="'table_add_' + pageModule"
                  ></icon-font>
                  <!-- 编辑 -->
                  <a-icon
                    type="edit"
                    class="edit-btn"
                    @click.stop="editFolder(nodeName, uuid)"
                    v-if="delBtn == 0"
                    v-action="'table_add_' + pageModule"
                  />
                  <!-- 删除 -->
                  <a-icon
                    type="delete"
                    class="delete-btn"
                    @click.stop="deleteFolder(uuid)"
                    v-if="delBtn == 0"
                    v-action="'table_add_' + pageModule"
                  />
                </div>
              </div>
            </template>
          </a-tree>
        </div>
      </div>
      <div class="about-right-container">
        <div class="sub-header">
          <a-button
            type="primary"
            v-if="currentTreeNode.uploadBtn"
            icon="cloud-upload"
            @click="uploadFolder()"
            v-action="'table_edit_' + pageModule"
          >
            上传
          </a-button>
          <a-button
            v-action="'table_edit_' + pageModule"
            v-if="currentTreeNode.zipBtn"
            type="primary"
            icon="file-zip"
            @click="handleUploadZip({}, 1)"
          >
            导入压缩包
          </a-button>
          <a-button
            v-if="currentTreeNode.id"
            v-action="'down_load_' + pageModule"
            type="primary"
            icon="download"
            @click="handleDownloadZip()"
            :disabled="tableData.length > 0 ? false : true"
            :loading="downloadLoading"
          >
            {{ downloadLoading ? "下载中" : "下载" }}
          </a-button>
          <a-button
            type="primary"
            icon="delete"
            @click="handleBatchDelete()"
            v-if="tableData.length > 0 && !showHeader"
          >
            批量删除
          </a-button>
          <a-button
            type="primary"
            @click="handleMoveModal()"
            icon="drag"
            v-if="tableData.length > 0 && !showHeader"
          >
            批量移动
          </a-button>
        </div>
        <div class="table-main">
          <div
            class="drag-drop-container"
            v-if="currentTreeNode.id && currentTreeNode.uploadBtn"
          >
            <dragDropUpload
              :treeItem="currentTreeNode"
              @onRefresh="getTableData($event)"
            ></dragDropUpload>
          </div>
          <!-- empty-text="新建/上传文件" -->
          <vxe-table
            ref="xTable"
            height="99%"
            align="center"
            show-overflow
            show-header-overflow
            border="inner"
            :data="tableData"
            :column-config="{ resizable: true }"
            size="small"
            :loading="tableLoading"
          >
            <vxe-table-column width="60" v-if="!showHeader">
              <template #header>
                <a-checkbox
                  v-model="allChecked"
                  :indeterminate="indeterminate"
                  @change="allClick($event)"
                  :disabled="showHeader"
                >
                </a-checkbox>
              </template>
              <template #default="{ row }">
                <a-checkbox
                  v-model="row.select"
                  @change="changeItem($event, row)"
                  :disabled="row.isDisabled"
                >
                </a-checkbox>
              </template>
            </vxe-table-column>
            <vxe-column type="seq" width="80" title="序号"></vxe-column>
            <vxe-column
              title="文件名称"
              field="fileName"
              min-width="300"
              align="left"
            >
              <template #default="{ row }">
                <div class="table-file-name">
                  <div
                    class="icon"
                    :class="[getFileIconName(row.fileName)]"
                  ></div>
                  <div class="name" @click="previewFile(row)">
                    {{ row.fileName }}
                  </div>
                </div>
              </template>
            </vxe-column>
            <vxe-column title="上传人" field="creator"> </vxe-column>
            <vxe-column title="上传时间" field="createTimeStr"> </vxe-column>
            <vxe-column title="查看/下载" width="160">
              <template #default="{ row }">
                <div class="files-icon">
                  <!-- 预览 -->
                  <a-tooltip placement="top">
                    <template slot="title">
                      预览
                    </template>
                    <a-icon type="eye" @click="previewFile(row)" />
                  </a-tooltip>
                  <!-- 下载 -->
                  <a-tooltip
                    placement="top"
                    v-action="'down_load_' + pageModule"
                  >
                    <template slot="title">
                      下载
                    </template>
                    <a-icon type="download" @click="downloadFile(row)" />
                  </a-tooltip>
                </div>
              </template>
            </vxe-column>
            <!-- <vxe-column field="correlation" title="关联模型" width="130">
              <template #default="{ row }">
                <div
                  class="correlation-model"
                  :class="!row.dataSetId && 'no'"
                  v-if="row.previewWay == 'cad'"
                  @click="row.previewWay && viewModalCad(row)"
                >
                  <icon-font
                    :type="row.dataSetId ? 'icon-wancheng' : 'icon-weiwancheng'"
                    class="location-button"
                  ></icon-font>
                  {{ row | relevanceText }}
                </div>
                <div v-else>-</div>
              </template>
            </vxe-column> -->

            <vxe-column
              field="operate"
              title="操作"
              fixed="right"
              width="80"
              align="left"
            >
              <template #default="{ row }">
                <div class="text-button-group">
                  <!-- 关联模型 -->
                  <!-- <a-tooltip placement="top" v-if="row.previewWay == 'cad'">
                    <template slot="title">
                      关联模型
                    </template>
                    <icon-fonts
                      icon="icon-guanlian"
                      @change="handleAgain(row)"
                    />
                  </a-tooltip> -->
                  <!-- 更新 -->
                  <a-tooltip
                    placement="top"
                    v-if="row.versionMain != 1"
                    v-action="'table_edit_' + pageModule"
                  >
                    <template slot="title">
                      更新
                    </template>
                    <icon-fonts
                      icon="icon-gengxin"
                      class="edit-btn"
                      @change="editFile(row)"
                    ></icon-fonts>
                  </a-tooltip>
                  <!-- 删除 -->
                  <a-tooltip
                    placement="top"
                    v-action="'file_delete_' + pageModule"
                    v-if="row.versionMain != 1"
                  >
                    <template slot="title">
                      删除
                    </template>
                    <a-icon
                      type="delete"
                      class="delete-btn"
                      @click="deleteFile(row.uuid)"
                    />
                  </a-tooltip>
                </div>
              </template>
            </vxe-column>
          </vxe-table>
        </div>
        <div class="table-pager">
          <vxe-pager
            size="small"
            background
            :current-page.sync="pager.page"
            :page-size.sync="pager.pageSize"
            :total="pager.total"
            :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'Sizes']"
            :page-sizes="[20, 50, 100, 500]"
            @page-change="paginationChange"
          >
            <template #left>
              <div class="vxe-pager-left-tip-container">
                共<span>{{ pager.total }}</span
                >条
              </div>
            </template>
          </vxe-pager>
        </div>
      </div>
    </div>
    <!-- 新增、编辑 目录弹窗 -->
    <addModal
      :visible.sync="addModal.visible"
      :operate="addModal.operate"
      :pid="addModal.pid"
      :nodeName="addModal.nodeName"
      @onRefresh="getTreeData()"
    ></addModal>
    <!-- 上传文件 -->
    <uploadModal
      :visible.sync="uploadModal.visible"
      :operate="uploadModal.operate"
      :treeItem="currentTreeNode"
      :parameter="uploadModal.row"
      @onRefresh="handleRefresh()"
    ></uploadModal>
    <!-- 普通附件预览-->
    <previewModal
      ref="previewModal"
      :visible.sync="previewModal.visible"
      :loading="previewModal.loading"
    ></previewModal>
    <!-- 批量移动 -->
    <moveModal
      :visible.sync="moveModal.visible"
      :parameter="moveModal.source"
      @moveChange="handleMoveChange()"
    ></moveModal>
    <!-- 关联模型 -->
    <associationModel
      :visible.sync="associationModel.visible"
      :row="associationModel.row"
      @change="getTableData()"
    ></associationModel>
    <!-- 上传压缩包 -->
    <uploadZipModal
      :visible.sync="uploadZipModal.visible"
      :operate="uploadZipModal.operate"
      :parameter="uploadZipModal.row"
      :treeItem="currentTreeNode"
      @onRefresh="handleRefresh()"
    ></uploadZipModal>
  </div>
</template>

<script>
// 工程勘察
import moment from "moment";
import { Icon } from "ant-design-vue";
import iconfrontjs from "@/assets/IconFont/iconfont.js";
const iconFrontUrl = iconfrontjs;
const IconFont = Icon.createFromIconfontCN({
  scriptUrl: iconFrontUrl,
});
import { axios } from "@/utils/request";
import { mapGetters } from "vuex";
import { getToken, downLoadBatchFileByArraybuffer } from "@/utils/TopVUI";
import {
  addAttributeByKey,
  flatTreeData,
  getFileIconName,
} from "@/utils/util.js";
import cloneDeep from "lodash.clonedeep";
import ScreenConditions from "@/components/extendCustom/ScreenConditions";
//新建目录
import addModal from "@/pages/customPage/design/drawingManage/components/addModal.vue";
//上传文件
import uploadModal from "@/pages/customPage/design/drawingManage/components/uploadModal.vue";
//拖拽上传
import dragDropUpload from "@/pages/customPage/design/drawingManage/components/dragDropUpload.vue";
//关联模型
import associationModel from "@/pages/customPage/design/drawingManage/components/associationModel.vue";
//预览
import previewModal from "@/pages/document/minio/previewModal";
//上传压缩包
import uploadZipModal from "./components/uploadZipModal.vue";
//批量移动
import moveModal from "./components/moveModal.vue";
import { exportZip } from "@/api/constructManage";
export default {
  provide() {
    return {
      moduleSource: () => this.pageModule,
    };
  },
  components: {
    IconFont,
    ScreenConditions,
    addModal,
    uploadModal,
    previewModal,
    dragDropUpload,
    moveModal,
    associationModel,
    uploadZipModal,
  },
  data() {
    return {
      //页面类型
      pageModule: 1,
      //查询体条件
      condition: {
        //文件名称
        fileName: undefined,
        //日期范围
        date: [],
        //上传人
        creator: "",
      },
      //目录分项
      expandedKeys: [],
      autoExpandParent: true,
      checkedKeys: [],
      selectedKeys: [],
      treeData: [],
      cloneTreeData: [],
      currentTreeNode: {},
      //table
      tableData: [],
      tableLoading: false,
      pager: {
        page: 1,
        pageSize: 50,
        total: 0,
      },
      //目录分项
      addModal: {
        visible: false,
        operate: 1,
        pid: "",
        nodeName: "",
      },
      //下载
      downloadLoading: false,
      //上传文件
      uploadModal: {
        visible: false,
        operate: 1,
        row: {},
      },
      //预览
      previewModal: {
        visible: false,
        loading: false,
      },
      //是否显示表全选按钮
      showHeader: false,
      //复选框
      allChecked: false,
      indeterminate: false,
      checkRowKeys: [],
      //批量移动弹窗
      moveModal: {
        visible: false,
        source: {},
        removeFileIdLs: [],
      },
      //关联模型
      associationModel: {
        visible: false,
        row: {},
        proCode: "",
      },
      //上传压缩包
      uploadZipModal: {
        visible: false,
        operate: 1,
        row: {},
      },
    };
  },
  computed: {
    menuName() {
      let { title } = this.$route.meta;
      return title;
    },
    ...mapGetters(["configData"]),
    kkFileView() {
      let index = this.configData.findIndex(
        (item) => item.code === "kkFileView"
      );
      if (index >= 0) {
        return this.configData[index].value;
      } else {
        return "http://192.168.1.216:8012/onlinePreview";
      }
    },
  },
  filters: {
    relevanceText(row) {
      let { dataSetId } = row;
      if (dataSetId) {
        return "已关联";
      } else {
        return "未关联";
      }
    },
  },
  mounted() {
    this.getTreeData();
  },
  methods: {
    moment,
    getFileIconName,

    //压缩包上传
    handleUploadZip(row, type) {
      this.uploadZipModal.operate = type;
      this.uploadZipModal.row = row;
      this.uploadZipModal.visible = true;
    },
    //压缩包下载
    handleDownloadZip() {
      let { id, nodeName } = this.currentTreeNode;
      if (!id) {
        return;
      }
      this.downloadLoading = true;
      exportZip({ classifyId: id })
        .then((data) => {
          downLoadBatchFileByArraybuffer(data, nodeName);
        })
        .catch((_) => {})
        .finally((_) => {
          this.downloadLoading = false;
        });
    },
    //新建文件夹
    addFolder(id) {
      this.addModal.operate = 1;
      this.addModal.pid = id;
      this.addModal.nodeName = "";
      this.addModal.visible = true;
    },
    //编辑文件夹
    editFolder(nodeName, uuid) {
      this.addModal.operate = 2;
      this.addModal.pid = uuid;
      this.addModal.nodeName = nodeName;
      this.addModal.visible = true;
    },
    //删除文件夹
    deleteFolder(uid = "") {
      let { uuid } = this.currentTreeNode;
      let that = this;
      that.$confirm({
        title: "提示",
        content: "确定删除该数据吗？删除之后不可恢复！",
        okText: "确定",
        cancelText: "取消",
        icon: () =>
          that.$createElement("a-icon", {
            props: {
              key: "warning",
              type: "exclamation-circle",
              twoToneColor: "#faad14",
            },
          }),
        onOk() {
          return new Promise((resolve, reject) => {
            that
              .$post(`/probusiness/bimCadClassify/deleteData?uuid=${uid}`)
              .then((res) => {
                let { statusCode, message } = res;
                if (statusCode == 200) {
                  that.$message.success("删除成功！");
                  if (uuid == uid) {
                    that.currentTreeNode = {};
                    that.tableData = [];
                  }
                  that.getTreeData();
                } else {
                  that.$message.error(message ?? "删除失败，请稍后重试！");
                }
                resolve();
              })
              .catch((_) => {})
              .finally((_) => {});
          }).catch(() => console.log("Oops errors!"));
        },
      });
    },
    //查询目录分项
    getTreeData() {
      return new Promise((resolve, reject) => {
        axios
          .post(
            `/probusiness/bimCadClassify/getTreeByProCode?type=${this.pageModule}`,
            {},
            {
              headers: {
                "Content-Type": "application/json",
              },
            }
          )
          .then((res) => {
            let { data } = res;
            this.cloneTreeData = cloneDeep(data ?? []);
            let flatData = flatTreeData(this.cloneTreeData, "children");
            this.expandedKeys = flatData.map((v) => v.uuid).filter((v) => v);
            let filterData = addAttributeByKey(
              null,
              "scopedSlots",
              { icon: "custom" },
              this.cloneTreeData,
              "children"
            );
            if (!this.currentTreeNode.uuid) {
              this.currentTreeNode = filterData?.[0] ?? {};
              this.getTableData();
            }
            this.selectedKeys = [this.currentTreeNode.uuid];
            this.treeData = filterData ?? [];
            resolve();
          })
          .catch((_) => {
            this.selectedKeys = [];
            this.expandedKeys = [];
            this.treeData = [];
            this.cloneTreeData = [];
            reject();
          })
          .finally((_) => {});
      });
    },
    onExpand(expandedKeys) {
      this.expandedKeys = expandedKeys;
      this.autoExpandParent = false;
    },
    //监听树形选择
    onSelect(selectedKeys, info) {
      let { uuid } = info.node.dataRef;
      this.currentTreeNode = info.node.dataRef;
      this.selectedKeys = [uuid];
      this.search();
    },
    search() {
      this.pager.page = 1;
      this.getTableData();
    },
    reset() {
      this.condition = {
        fileName: "",
        date: [],
        creator: "",
      };
      this.search();
    },
    //监听分页切换
    paginationChange({ currentPage, pageSize }) {
      this.pager.page = currentPage;
      this.pager.pageSize = pageSize;
      this.getTableData();
    },
    //分页列表
    getTableData() {
      let { id } = this.currentTreeNode;
      let { fileName, date, creator } = this.condition;
      if (!id) {
        this.tableData = [];
        return;
      }
      this.tableLoading = true;
      let { page, pageSize } = this.pager;
      axios
        .post(
          `/probusiness/bimCadFile/getPageSet?pageNo=${page}&pageSize=${pageSize}`,
          {
            classifyId: id,
            fileName,
            creator,
            startTime: date?.[0] ?? "",
            endTime: date?.[1] ?? "",
            type: this.pageModule,
          },
          {
            headers: {
              "Content-Type": "application/json",
            },
          }
        )
        .then((res) => {
          let { data } = res;
          this.tableData = data?.rows ?? [];
          this.pager.total = data?.totalCount ?? 0;
          this.tableData.forEach((item) => {
            if (this.checkRowKeys.includes(item.uuid)) {
              this.$set(item, "select", true);
              this.$set(item, "isDisabled", false);
            } else {
              this.$set(item, "select", false);
              if (item.versionMain == 1) {
                this.$set(item, "isDisabled", true);
              } else {
                this.$set(item, "isDisabled", false);
              }
            }
          });
          this.resetBatchCheckBox();
        })
        .catch((_) => {
          this.tableData = [];
          this.pager.total = 0;
          reject();
        })
        .finally((_) => {
          this.tableLoading = false;
        });
    },
    //重置全选按钮
    resetBatchCheckBox() {
      this.showHeader = this.tableData.every((v) => v.versionMain == 1);
      let filterArray = this.tableData.filter((v) => v.versionMain != 1);
      try {
        filterArray.forEach((v) => {
          if (v.select) {
            throw v;
          }
        });
        this.indeterminate = false;
      } catch (error) {
        this.indeterminate = true;
      }
      const ids = filterArray.filter((item) => item.select).map((v) => v.uuid);
      if (ids.length == filterArray.length) {
        this.indeterminate = false;
      }
      if (filterArray.length > 0) {
        this.allChecked = filterArray.every((v) => v.select);
      } else {
        this.allChecked = false;
      }
    },
    handleRefresh() {
      this.getTreeData().then((res) => {
        this.getTableData();
      });
    },
    //上传文件
    uploadFolder() {
      this.uploadModal.operate = 1;
      this.uploadModal.row = {};
      this.uploadModal.visible = true;
    },
    //文件编辑
    editFile(row = {}) {
      this.uploadModal.operate = 2;
      this.uploadModal.row = row;
      this.uploadModal.visible = true;
    },
    //文件删除
    deleteFile(uuid = "") {
      let that = this;
      that.$confirm({
        title: "提示",
        content: "确定删除该数据吗？删除之后不可恢复！",
        okText: "确定",
        cancelText: "取消",
        icon: () =>
          that.$createElement("a-icon", {
            props: {
              key: "warning",
              type: "exclamation-circle",
              twoToneColor: "#faad14",
            },
          }),
        onOk() {
          return new Promise((resolve, reject) => {
            that
              .$post(`/probusiness/bimCadFile/deleteBatch?uuid=${uuid}`)
              .then((res) => {
                let { statusCode } = res;
                if (statusCode == 200) {
                  that.$message.success("删除成功！");
                  that.getTableData();
                } else {
                  that.$message.error("删除失败，请稍后重试！");
                }
                resolve();
              })
              .catch((_) => {
                reject();
              })
              .finally((_) => {});
          }).catch(() => console.log("Oops errors!"));
        },
      });
    },
    //文件预览
    previewFile(row = {}) {
      let { previewWay, uuid, fileInfo, unit, bhDataSetId, bhFileName } = row;
      let { fileName, url } = fileInfo;
      let domain = location.origin;
      switch (previewWay) {
        //cad预览
        case "cad":
          window.open(
            `${domain}/#/blackHole/previewCad?uuid=${uuid}&fileName=${fileName}&unit=${unit}`
          );
          return;
        // 模型预览
        case "model":
          bhDataSetId &&
            window.open(
              `${domain}/#/blackHole/viewDataSetSingleSimple?dataSetId=${bhDataSetId}&name=${bhFileName}`
            );
          return;
        // 普通文件预览
        case "kkview":
          this.previewModal.loading = true;
          this.$refs.previewModal.type = "file";
          this.$refs.previewModal.fileUrl =
            this.kkFileView +
            "/onlinePreview?url=" +
            encodeURIComponent(Base64.encode(url)) +
            "&watermarkTxt=" +
            //水印内容
            encodeURIComponent("") +
            "&token=" +
            getToken();
          this.previewModal.visible = true;
          this.previewModal.loading = false;
          return;
        default:
          break;
      }
    },
    //文件下载
    downloadFile(row = {}) {
      let { fileInfo } = row;
      let { url, fileName } = fileInfo;
      // 创建一个<a>元素
      const link = document.createElement("a");
      link.href = url; // 设置图片的URL
      link.download = fileName; // 设置下载后的文件名
      document.body.appendChild(link); // 将<a>元素添加到页面中
      link.click(); // 模拟点击<a>元素
      document.body.removeChild(link); // 移除<a>元素
    },
    //全选
    allClick() {
      this.indeterminate = false;
      if (this.allChecked) {
        this.tableData.forEach((v) => {
          if (v.versionMain != 1) {
            this.$set(v, "select", true);
          }
        });
        let filterArray = this.tableData.filter((v) => v.versionMain != 1);
        this.checkRowKeys = filterArray.map((v) => v.uuid);
      } else {
        this.tableData.forEach((v) => {
          this.$set(v, "select", false);
        });
        this.checkRowKeys = [];
      }
    },
    //单选
    changeItem(event, row) {
      let { checked } = event.target;
      let { uuid } = row;
      if (checked) {
        this.checkRowKeys.push(uuid);
        this.checkRowKeys = Array.from(new Set(this.checkRowKeys));
      } else {
        this.checkRowKeys = this.checkRowKeys.filter((v) => v != uuid);
      }
      let filterArray = this.tableData.filter((v) => v.versionMain != 1);
      this.allChecked = filterArray.every((v) => v.select);
      this.indeterminate =
        !!this.checkRowKeys.length &&
        this.checkRowKeys.length < filterArray.length;
    },
    //批量删除
    handleBatchDelete() {
      if (this.checkRowKeys.length == 0) {
        this.$message.warning("请选择需要删除的文件！");
        return;
      }
      let that = this;
      that.$confirm({
        title: "提示",
        content: "确定删除该数据吗？删除之后不可恢复！",
        okText: "确定",
        cancelText: "取消",
        icon: () =>
          that.$createElement("a-icon", {
            props: {
              key: "warning",
              type: "exclamation-circle",
              twoToneColor: "#faad14",
            },
          }),
        onOk() {
          return new Promise((resolve, reject) => {
            axios
              .post(
                `/probusiness/bimCadFile/deleteFileBatch`,
                {
                  fileUuid: that.checkRowKeys,
                },
                {
                  headers: {
                    "Content-Type": "application/json",
                  },
                }
              )
              .then((res) => {
                let { statusCode } = res;
                if (statusCode == 200) {
                  that.$message.success("删除成功！");
                  that.checkRowKeys;
                  that.getTableData();
                } else {
                  that.$message.error("删除失败，请稍后重试！");
                }
                resolve();
              })
              .catch((_) => {
                reject();
              })
              .finally((_) => {});
          }).catch(() => console.log("Oops errors!"));
        },
      });
    },
    //批量移动
    handleMoveModal() {
      if (this.checkRowKeys.length == 0) {
        this.$message.warning("请选择需要移动的文件！");
        return;
      }
      let { pageModule, checkRowKeys } = this;
      this.moveModal.source = {
        pageModule,
        checkRowKeys,
      };
      this.moveModal.visible = true;
    },
    handleMoveChange() {
      this.allChecked = false;
      this.indeterminate = false;
      this.checkRowKeys = [];
      this.getTableData();
    },
    //关联模型
    handleAgain(row) {
      this.associationModel.row = row;
      this.associationModel.visible = true;
    },
    //预览关联后的模型和cad
    viewModalCad(row) {
      let { dataSetId, componentId, fileName, uuid } = row;
      let domain = location.origin;
      window.open(
        `${domain}/#/blackHole/previewCadBim?dataSetId=${dataSetId}&nodeId=${componentId}&cadId=${uuid}&name=${fileName}`
      );
    },
  },
};
</script>

<style lang="less" scoped>
.table-main {
  position: relative;

  .correlation-model {
    color: #1677ff;
    font-size: 14px;
    cursor: pointer;
    &:hover {
      text-decoration: underline;
    }
    .anticon {
      color: #239b53;
      margin-right: 6px;
    }
    &.no {
      text-decoration: none;
      cursor: default;
      .anticon {
        color: #ff2d2d;
      }
    }
  }
  .drag-drop-container {
    z-index: 22;
    position: absolute;
    left: 60px;
    height: 100%;
    width: 66%;
  }
}
</style>
